package Visitor;

import Controllers.Application;
import Entities.*;
import Entities.Advantages.*;
import java.awt.Color;
import java.awt.Graphics;

public class PaintVisitor implements IVisitor {

    private Graphics g;
    private Application application;

    public PaintVisitor(Application application, Graphics g) {
        this.application = application;
        this.g = g;
    }

    @Override
    public Drawable visit(Bar bar) {
        g.drawRect((int)bar.getX(), (int)bar.getY(), (int)bar.getWidth(), (int)bar.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Ball ball) {
        if (ball.getDx() == 0 && ball.getDy() == 0) {
            g.drawString("Press SPACE", 170, 200);
        }
        g.fillOval((int)ball.getX(), (int)ball.getY(), (int)ball.getRadio() * 2, (int)ball.getRadio() * 2);
        return null;
    }

    @Override
    public Drawable visit(Boundary boundary) {
        g.drawRect((int)boundary.getX(), (int)boundary.getY(), (int)boundary.getWidth(), (int)boundary.getHeight());
        return null;
    }

    @Override
    public Drawable visit(IAdvantage advantage) {
        g.fillRect((int)advantage.getX(), (int)advantage.getY(), (int)advantage.getWidth(), (int)advantage.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Brick brick) {
        switch (brick.getResistance()) {
            case 1: {
                g.setColor(Color.blue);
                break;
            }
            case 2: {
                g.setColor(Color.red);
                break;
            }
            case 3: {
                g.setColor(Color.yellow);
                break;
            }
            case 4: {
                g.setColor(Color.green);
                break;
            }
            default: {
            }
        }
        if (brick.getResistance() != 0) {
            g.fillRect((int)brick.getX(), (int)brick.getY(), (int)brick.getWidth(), (int)brick.getHeight());
            g.setColor(Color.black);
        }
        g.drawRect((int)brick.getX(), (int)brick.getY(), (int)brick.getWidth(), (int)brick.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Drawable drawable) {
        return null;
    }

    @Override
    public Drawable visit(Hinder hinder) {
        return null;
    }

    @Override
    public Drawable visit(DecreaseBarSize dicreaseBarSize) {
        g.setColor(Color.red);
        g.fillRect((int)dicreaseBarSize.getX(), (int)dicreaseBarSize.getY(), (int)dicreaseBarSize.getWidth(), (int)dicreaseBarSize.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(IncreaseBarSize increaseBarSize) {
        g.setColor(Color.green);
        g.fillRect((int)increaseBarSize.getX(), (int)increaseBarSize.getY(), (int)increaseBarSize.getWidth(), (int)increaseBarSize.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(DecreaseBallSpeed drecreaseBallSpeed) {
        g.setColor(Color.green);
        g.fillRect((int)drecreaseBallSpeed.getX(), (int)drecreaseBallSpeed.getY(), (int)drecreaseBallSpeed.getWidth(), (int)drecreaseBallSpeed.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(IncreaseBallSpeed increaseBallSpeed) {
        g.setColor(Color.red);
        g.fillRect((int)increaseBallSpeed.getX(), (int)increaseBallSpeed.getY(), (int)increaseBallSpeed.getWidth(), (int)increaseBallSpeed.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(MissileAdvantage missileAdvantage) {
        return null;
    }

    @Override
    public Drawable visit(ThreeBallsAdvantage threeBallsAdvantage) {
        g.setColor(Color.red);
        g.fillRect((int)threeBallsAdvantage.getX(), (int)threeBallsAdvantage.getY(), (int)threeBallsAdvantage.getWidth(), (int)threeBallsAdvantage.getHeight());
        g.setColor(Color.black);
        return null;
    }
}
